package com.example.dellpc.myapplication;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;


import java.util.ArrayList;
import java.util.List;

/**
 * Created by 刘智强 on 2016/8/8.
 */

public class MyAdapter extends RecyclerView.Adapter<MyAdapter.ViewHodler> {

    private Context context;
  private   List<String> datas=new ArrayList<>();

    public MyAdapter(Context context,List<String> datas) {
        this.context = context;
        this.datas=datas;
    }

    @Override
    public ViewHodler onCreateViewHolder(ViewGroup parent, int viewType) {
        return new ViewHodler(LayoutInflater.from(context).inflate(R.layout.listview_item,parent,false));

    }

    @Override
    public void onBindViewHolder(ViewHodler holder, final int position) {
holder.textView.setText(datas.get(position));
        Log.d("TAG","绑定数据源...");
    }

    @Override
    public int getItemCount() {
        return datas.size();
    }


    public  class ViewHodler extends RecyclerView.ViewHolder{
        TextView textView;

        public ViewHodler(View itemView) {
            super(itemView);
            textView= (TextView) itemView.findViewById(R.id.tv_name);


        }
    }
}
